#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <assert.h>

int main()
{
	char arr[] = " bcdad";
	size_t a = strlen(arr);
	printf("%zd", a);
	return 0;
}

size_t my_strlen(char arr[])
{
	assert(arr);
	int count = 0;
	char* a = arr;
	while (*a != '\0')
	{
		count++;
		a++;
	}
	return (size_t)count;
}

int main()
{
	char arr[] = "abhudk";
	size_t a = my_strlen(arr);
	printf("%zd", a);
	return 0;
}

size_t my_strlen(char* arr)
{

	if (*arr == '\0')
		return 0;
	else
		return 1 + my_strlen(arr+1);
}

int main()
{
	char arr[] = "abchdiua";
	size_t a = my_strlen(&arr);
	printf("%zd", a);
	return 0;
}

size_t my_strlen(char* arr)
{
	char* left = arr;
	char* right = NULL;
	while (1)
	{
		if (*arr == '\0')
		{
			right = arr;
			break;
		}
		arr++;
	}
	return right - left;
}

int main()
{
	char arr[] = "abchdiua";
	size_t a = my_strlen(&arr);
	printf("%zd", a);
	return 0;
}

int main()
{
	char arr[] = "hsbxa";
	char arr2[20] = "ndxxxxxxxxxxxxxxxx";
	strcpy(arr2, arr);
	printf("%s", arr2);
	return 0;
}

char* my_strcpy(char* arr2, char* arr)
{
	assert(arr2 && arr);
	char* p = arr2;
	while ( * arr2++ = *arr++)
	{
		;
	}
	
	return p;
}

int main()
{
	char arr[] = "hsbxa";
	char arr2[20] = "ndxxxxxxxxxxxxxxxx";
	char* p = my_strcpy(arr2, arr);
	printf("%s", p);
	return 0;
}

int main()
{
	char arr[] = "hsbxa";
	char arr2[20] = "ndxxxxx";
	strcat(arr2, arr);
	printf("%s", arr2);
	return 0;
}

char* my_strcat(char* arr2, char* arr)
{
	assert(arr2 && arr);
	char* p = arr2;
	while (*arr2!='\0')
	{
		arr2++;
	}
	while (*arr2++ = *arr++);
	return p;

}

int main()
{
	char arr[] = "hsbxa";
    char arr2[20] = "ndxxxxx";
	char* p = my_strcat(arr2, arr);
	printf("%s", p);
	return 0;
}

int main()
{
	char arr1[] = "abcde";
	char arr2[] = "abcdf";
	int a = strcmp(arr1, arr2);
	printf("%d", a);
	return 0;
}

int my_strcmp(const char* arr1, const char* arr2)
{
	assert(arr1 && arr2);
	while (*arr1 == *arr2)
	{
		if (*arr1 == '\0' && *arr2 == '\0')
			return 0;
		arr1++;
		arr2++;
	}
	if (*arr1 - *arr2 > 0)
		return 1;
	else
		return -1;
	
}

int main()
{
	char arr1[] = "abcd";
	char arr2[] = "abcde";
	int a = my_strcmp(arr1,arr2);
	printf("%d", a);
	return 0;
}

int main()
{
	char arr[] = "hsbxa";
	char arr2[20] = "ndxxxxx";
	char* p = strncpy(arr2, arr,1);
	printf("%s", p);
	return 0;
}

char* my_strncpy(char* arr2, const char* arr, int sz)
{
	assert(arr2 && arr);
	char* p = arr2;
	while (sz)
	{
		*arr2 = *arr;
		sz--;
		arr2++;
		arr++;
	}
	return p;
}

int main()
{
	char arr[] = "hsbxa";
	char arr2[20] = "ndxxxxx";
	char* p = my_strncpy(arr2, arr, 4);
	printf("%s", p);
	return 0;
}